<?php

	define('TEMPLATE_ROOT', dirname(__FILE__) . '/');
	define('HOST', $_SERVER['HTTP_HOST']);
	
	require_once('../vivvo_template_engine.php');
	
	$template = new template();
	$template->set_template_file('index.tpl');
	
	$template->assign('TITLE', 'Vivvo Template Engine');
	
	$list_template = new template();
	$list_template->set_template_file('list.tpl');
	$list = array();
	$list[] = 	array(
					'title'		=>	'Template tags', 
					'href' 		=>	'#tags',
					'sub_list'	=>	array(
									array(				
										'title'	=>	'{if}', 
										'href' 	=>	'#if'
									),
									array(				
										'title'	=>	'{foreach}', 
										'href' 	=>	'#foreach'
									),
									array(				
										'title'	=>	'{literal}',
										'href' 	=>	'#literal'
									),
									array(				
										'title'	=>	'{include}',
										'href' 	=>	'#include'
									),
									array(				
										'title'	=>	'{$variable}', 
										'href' 	=>	'#variable'
									)
								)								
				);
	$list[] = 	array(
					'title'		=>	'Demo source code', 
					'href' 		=>	'#demo_source'
				);
	$list[] = 	array(
					'title'		=>	'This list template code', 
					'href' 		=>	'#list_template'
				);
								
	$list_template->assign('list', $list);
				
	$template->assign('test_list', $list[0]);
	$template->assign_template('list', $list_template);

	class test{
		var $a;
		
		function get_a(){
			return 'Hello ' . $this->a;
		}
		
		function test(){
			$this->a = 'world';
		}
	}
	$object = new test();
	$template->assign('object', $object);
	
	
	$source = file_get_contents('index.php');
	$source = htmlspecialchars($source);
	$template->assign('source', $source);
	
	$list_template_source = file_get_contents('list.tpl');
	$list_template_source = htmlspecialchars($list_template_source);
	$template->assign('list_template_source', $list_template_source);
	
	echo $template->get_output();
?>